<?php

namespace App\Http\Controllers;

use App\Models\Slide;
use App\Models\Video;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class SlideController extends CommonController
{
    /**
     * 轮播图列表
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request)
    {
        $slides = Slide::where('status', '1')->select('id', 'icon')
            ->orderBy('id', 'desc')->skip(0)->take(5)->get();
        if ($slides) {
            foreach ($slides as $v) {
                $v->icon = $v->icon ? self::$baseImgUrl . '/' . $v->icon : '';
            }
        }

        return response()->json(['status' => 1, 'data' => $slides]);
    }
}
